#include <AnalogButtons.h>

HardwareSerial Serial(PA10, PA9);

void up()
{
  Serial.println("↑");
}

void down()
{
  Serial.println("↓");
}

void left()
{
  Serial.println("←");
}

void right()
{
  Serial.println("→");
}

void press()
{
  Serial.println("●");
}

AnalogButtons analogButtons(PA0, INPUT);
Button bu = Button(520, up);
Button bd = Button(120, down);
Button bl = Button(385, left);
Button br = Button(738, right);
Button bp = Button(630, press);

void setup() {
  Serial.begin(9600); 
  Serial.println("测试五向按键");
  
  pinMode(PA8, INPUT);
  analogButtons.add(bu);
  analogButtons.add(bd);
  analogButtons.add(bl);
  analogButtons.add(br);
  analogButtons.add(bp);  
}

void loop() {
  //检测是否有按键按下
  if (digitalRead(PA8) == HIGH)
  {
    analogButtons.check();
  }
  
  //打开注释代码，检测按键电压
  
  //unsigned int value = analogRead(PA0);
  //Serial.println(value);
  //delay(250);
}
